﻿using CPPEI.ETL.DataServiceInterface;
using CPPEI.WebApi;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using ENT = CPPEI.ETL.Domain.Entities;
using MOD = CPPEI.ETL.Domain.Models;
using SER = CPPEI.ETL.Domain.Services;

namespace CPPEI.ETL.WebApi.IntegrityCheck
{
    [CPPEI.WebApi.AuthPostAction("IntegrityCheck", "DeleteInstance", "1.0")]
    public class DeleteInstanceAction : BaseAction<DeleteInstanceParams, DeleteInstanceResult>
    {
        protected override ActionResult<DeleteInstanceResult> OnExecute(ActionContext context, 
            SysParameters sysParameters,
            DeleteInstanceParams opParams)
        {
            ServiceResult serResult = new SER.DeleteService().DeleteIntegrityCheckInstance(context.UserId, opParams.Id);
            if(serResult.IsSuccess)
            {
                DeleteInstanceResult result = new DeleteInstanceResult();
                return new ActionResult<DeleteInstanceResult>(result);
            }
            else
            {
                return new ActionResult<DeleteInstanceResult>(serResult.IsSuccess, serResult.ErrorCode, serResult.Message, null);
            }
        }
    }

    public class DeleteInstanceParams
    {
        [Parameter]
        public Guid Id { get; set; }
    }

    public class DeleteInstanceResult
    {
    }
}
